package com.jiang.daily.Q1742;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/02/13 0:13
 */
class Solution {
    public int countBalls(int lowLimit, int highLimit) {
        Map<Integer, Integer> map = new HashMap<>();
        int res = 0;
        while(lowLimit <= highLimit) {
            int box = 0;
            int num = lowLimit;
            while(num != 0) {
                box += num % 10;
                num /= 10;
            }
            map.compute(box, (k, v) -> v != null ? v + 1 : 1);
            res = Math.max(res, map.get(box));
            lowLimit++;
        }
        return res;
    }
}
